#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/7/21
# @Author  : LiJun
# @Email   : lijun@tianyancha.com
# @Version : 1.0.0
import requests

from conf import config as cf


class BaseApi:
    def __init__(self):
        self.token = self.get_token()

    def get_token(self):
        url = f"{cf.BASE_URL}/gettoken?corpid={cf.CORPID}&corpsecret={cf.CORPSECRET}"
        r = requests.get(url)
        return r.json().get('access_token', None)

    def send(self, method: str, url: str, **kwargs):
        return requests.request(method, f"{cf.BASE_URL}{url}", **kwargs)
